<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>全局组件和局部组件</title>
  </head>
  <body>
    <div id="app">
      <cpn2></cpn2>
      <cpn1></cpn1>
    </div>
    <script src="../vue.js"></script>
    <script>
      //1.创建组件构造器(子组件)
      const cpnC1 = Vue.extend({
        template: `
        <div>
          <h4>我是标题</h4>
          <p>我是内容 ，嘻嘻</p>
        </div>`,
      });
      //2.创建组件构造器(父组件)
      const cpnC2 = Vue.extend({
        template: `
        <div>
          <h4>我是标题</h4>
          <p>我是内容,哈哈</p>
          <cpn1></cpn1>
        </div>`,
        components: {
          cpn1: cpnC1,
        },
      });
      const app = new Vue({
        el: "#app",
        data: {
          message: "hello",
        },
        components: {
          cpn2: cpnC2,
          cpn1: cpnC1,
        },
      });
    </script>
  </body>
</html>
